﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Eis51.CampanyCMS.Business.Bus
{
    public  class WLog
    {

        /// <summary>
        /// 将文本写入日志文件
        /// </summary>
        /// <param name="txt"></param>
        public  static void WriteTextToFile(string txt)
        {
            StreamWriter sw = null;
            try
            {
                string FileName = System.Web.HttpContext.Current.Server.MapPath("~/") + DateTime.Now.ToString("yyyyMMdd") + ".log";

              
                FileInfo finfo = new FileInfo(FileName);
                if (!finfo.Exists)
                {
                    sw = File.CreateText(FileName);
                }
                else
                {
                    sw = new StreamWriter(finfo.OpenWrite());
                }
                sw.BaseStream.Seek(0, SeekOrigin.End);
                sw.Write(txt);
                sw.Flush();
            }
            catch
            {
            }
            finally
            {
                if (sw!=null)  sw.Close();
            }
        }


    }
}
